<template>
	<view>
		<button @click="OnSetTimeOut()" type="primary">单次计时器</button>
		<button @click="OnSetTimeOut('fqm',531)" type="primary" plain="true">启动传参计时器</button>
		<button @click="OnClearTimeOut()" type="warn">取消计时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		methods: {
			OnSetTimeOut() {
				console.log("onSetTimeOut()");
				// callback,ms,args
				setTimeout(() => {
					console.log("onSetTimeOut() callback");
				}, 3000);
			},
			// OnSetTimeOut(username, pwd) {
			// 	console.log("onSetTimeOut()", username, pwd);
			// 	setTimeout((x, y) => {
			// 		console.log("----callback", x, y);
			// 	}, 2000, username, pwd)
			// },
			OnClearTimeOut() {
				if (this.timerId) {
					clearTimeout(this.timerId);
					this.timerId = null;
					console.log("计时器已取消");
				}
			}
		}
	}
</script>

<style>

</style>